package com.qianfeng.openapi.web.master.mapper;

import com.qianfeng.openapi.web.master.pojo.AdminUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface AdminUserMapper {

    int deleteByPrimaryKey(Integer id);

    int insert(AdminUser record);

    int insertSelective(AdminUser record);

    AdminUser selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(AdminUser record);

    int updateByPrimaryKey(AdminUser record);

    @Select("select * from admin_user where email = #{email} and status = 1")
    AdminUser findByEmail(@Param("email") String email);

    List<AdminUser> findByRealNameAndEmailAndStatus(Map<String, Object> parameters);


    int updateStatusByIdIn(Integer[] ids);

    @Select("select role_id from user_role where user_id = #{userId}")
    List<Integer> findRoleIdByUserId(@Param("userId") Integer userId);

    // 删除用户的全部角色信息
    @Delete("delete from user_role where user_id = #{userId}")
    void deleteUserRoleByUserId(@Param("userId") Integer userId);

    // 添加用户角色信息
    int insertUserRole(@Param("userId") Integer userId, @Param("roleIds") Integer[] roleId);

    // 查询全部用户信息
    @Select("select * from admin_user")
    List<AdminUser> findAll();
}